package fms.dao;

import fms.model.ServiceStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Service("serviceStatusService")
public class ServiceStatusServiceImpl implements ServiceStatusService {
//    private Logger windCalcLogger = Logger.getLogger("windCalc");

    @PersistenceContext
    private EntityManager em;

    @Autowired
    private ServiceStatusDao serviceStatusDao;

//    // 新增
//    // 自动提交事务
//    @Transactional
//    public CptInfo save(CptInfo cptInfo) {
//        return cptInfoDao.save(cptInfo);
//    }

//    @Transactional
//    public Iterable<CptInfo> save(Iterable<CptInfo> cptInfo) {
//        return cptInfoDao.save(cptInfo);
//    }

    // 新增 + 更新
    @Transactional
    public ServiceStatus saveOrUpdate(ServiceStatus serviceStatus) {
        return serviceStatusDao.saveAndFlush(serviceStatus);
    }
//
//    @Override
//    public long count() {
//        return cptInfoDao.count();
//    }
//
//    @Transactional
//    @Override
//    public void delete(CptInfo cptInfo) {
//        cptInfoDao.delete(cptInfo);
//    }
//
//    @Transactional
//    @Override
//    public void deleteById(int id) {
//        cptInfoDao.deleteById(id);
//    }
//
//
//    @Transactional
//    @Override
//    public void deleteAll() {
//        cptInfoDao.deleteAll();
//    }

    @Override
    public Iterable<ServiceStatus> findAll() {
        return serviceStatusDao.findAll();
    }

//    @Override
//    public ServiceStatus findById(int id) {
//        return serviceStatusDao.findById(id);
//    }

    @Override
    public ServiceStatus findByServicecode(String servicecode) {
        return serviceStatusDao.findByServiceCode(servicecode);
    }


}
